package cn.com.project;

import org.redisson.misc.Hash;

import java.io.FileInputStream;
import java.io.InputStream;
import java.security.MessageDigest;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;

public class FileSHA256 {
    public static void main(String[] args) throws Exception {
        String filePath = "E:\\dist.zip"; // 替换为你的文件路径
        String sha256 = getFileSHA256(filePath);
        System.out.println("SHA-256: " + sha256);
    }
 
    private static String getFileSHA256(String filePath) throws Exception {
        InputStream fis = new FileInputStream(filePath);
        byte[] buffer = new byte[1024];
        MessageDigest complete = MessageDigest.getInstance("SHA-256");
        int read = 0;
        
        while((read = fis.read(buffer)) != -1) {
            complete.update(buffer, 0, read);
        }
        
        fis.close();
        byte[] b = complete.digest();
        
        String result = "";
        for (int i = 0; i < b.length; i++) {
            result += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);
        }
        return result;
    }

    public static void main2(String[] args) {
        StringBuilder sb = new StringBuilder();
        ArrayList arrayList = new ArrayList();
        HashMap hashMap = new HashMap();
        String str = "1231";
        System.out.println(str.indexOf("-2"));
        
    }


}